package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.p2p.base.util.MaskUtil;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.apache.ibatis.annotations.Case;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class RealAuth extends BaseAuthDomain {
    public static final int SEX_MALE = 0;//性别男
    public static final int SEX_FEMALE = 1;//性别女

    private String realName;//真实姓名
    private int sex;//性别
    private String idNumber;//身份证号码
    private String bornDate;//出生年月
    private String address;//身份证地址
    private String image1;//身份证正面
    private String image2;//身份证反面

    /**
     * 三元运算符 返回性别字符串是男还是女
     * @return
     */
    public String getSexDisplay(){
        return this.sex == SEX_MALE ? "男" : "女";
    }


    public String getJsonstring(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",super.getId());
        map.put("realName",realName);
        map.put("sex",getSexDisplay());
        map.put("idNumber",idNumber);
        map.put("bornDate",bornDate);
        map.put("address",address);
        map.put("image1",image1);
        map.put("image2",image2);
        map.put("applierName",super.getApplier().getUsername());
        map.put("state",super.getState());
        return JSON.toJSONString(map);
    }

    public String getAnonymousRealName() {
        return MaskUtil.getAnonymousRealName(realName);
    }

    public String getAnonymousIdNumber() {
        return MaskUtil.getAnonymousIdNumber(idNumber);
    }

    public String getAnonymousAddress() {
        return MaskUtil.getAnonymousIdNumber(address);
    }
}
